home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / createiorequest.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  94 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: createiorequest.c,v 1.4 1996/08/13 13:55:59 digulla Exp $
  4.     $Log: createiorequest.c,v $
  5.     Revision 1.4  1996/08/13 13:55:59  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:08  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "exec_intern.h"
  17. #include <exec/io.h>
  18. #include <exec/ports.h>
  19. #include <exec/memory.h>
  20. #include <aros/libcall.h>
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <exec/io.h>
  26.     #include <exec/ports.h>
  27.     #include <clib/exec_protos.h>
  28.  
  29.     __AROS_LH2(struct IORequest *, CreateIORequest,
  30.  
  31. /*  SYNOPSIS */
  32.     __AROS_LHA(struct MsgPort *, ioReplyPort, A0),
  33.     __AROS_LHA(ULONG,            size,        D0),
  34.  
  35. /*  LOCATION */
  36.     struct ExecBase *, SysBase, 109, Exec)
  37.  
  38. /*  FUNCTION
  39.     Create an I/O request structure bound to a given messageport.
  40.     I/O requests are normally used to communicate with exec devices
  41.     but can be used as normal messages just as well.
  42.  
  43.     INPUTS
  44.     ioReplyPort - Pointer to that one of your messageports where
  45.               the messages are replied to. A NULL port is legal
  46.               but then the function fails always.
  47.     size        - Size of the message structure including the struct
  48.               IORequest header. The minimal allowable size is that
  49.               of a struct Message.
  50.  
  51.     RESULT
  52.     Pointer to a new I/O request structure or NULL if the function
  53.     failed.
  54.  
  55.     NOTES
  56.  
  57.     EXAMPLE
  58.  
  59.     BUGS
  60.  
  61.     SEE ALSO
  62.  
  63.     INTERNALS
  64.  
  65.     HISTORY
  66.  
  67. ******************************************************************************/
  68. {
  69.     __AROS_FUNC_INIT
  70.  
  71.     struct IORequest *ret=NULL;
  72.  
  73.     /* A NULL ioReplyPort is legal but has no effect */
  74.     if(ioReplyPort==NULL)
  75.     return NULL;
  76.  
  77.     /* Allocate the memory */
  78.     ret=(struct IORequest *)AllocMem(size,MEMF_PUBLIC|MEMF_CLEAR);
  79.  
  80.     if(ret!=NULL)
  81.     {
  82.     /* Initialize it. */
  83.     ret->io_Message.mn_ReplyPort=ioReplyPort;
  84.  
  85.     /* This size is needed to free the memory at DeleteIORequest() time. */
  86.     ret->io_Message.mn_Length=size;
  87.     }
  88.  
  89.     /* All done. */
  90.     return ret;
  91.     __AROS_FUNC_EXIT
  92. } /* CreateIORequest */
  93.  
  94.